﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.EFCore
{
    public class DictionaryCategoryMapping : IEntityTypeConfiguration<DictionaryCategory>
    {
        public void Configure(EntityTypeBuilder<DictionaryCategory> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.Category).HasMaxLength(50);
            builder.Property(x => x.Name).HasMaxLength(50);
            builder.Property(x => x.Remark).IsRequired(false).HasMaxLength(500);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.Category);
            builder.HasIndex(x => x.Name);
            builder.HasIndex(x => x.CreatedOn).IsDescending();
        }
    }
}
